<template>
<slot :controller="controller" :store="store" :model="model">
    <div :class="classNames">
        <slot name="page_containerContainer" :controller="controller" :store="store" :model="model" >
        <AppStandardContainer 
            name="page_container"
            v-show="store.layoutModelDetails?.page_container?.visible"
            :isMultiContainer="false"
            :layoutModelDetails="store.layoutModelDetails">
            <template #container_grid1>
                <slot name="container_grid1Container" :controller="controller" :store="store" :model="model" >
                <AppSimpleFlexContainer 
                    name="container_grid1"
                    :layoutModelDetails="store.layoutModelDetails">
                    <template #container2>
                        <slot name="container2Container" :controller="controller" :store="store" :model="model" >
                        <AppSimpleFlexContainer 
                            name="container2"
                            :layoutModelDetails="store.layoutModelDetails">
                            <template #view_pagecaption>
                                <slot name="view_pagecaption" :controller="controller" :store="store" :model="model"  :actions="{ handleComponentAction }">
                                <AppPresetCaption 
                                    v-if="model.showCaption && !noViewCaption"
                                    name="view_pagecaption"
                                    @component-action="(actionParam: IEvent<string>) => { handleComponentAction(controller, actionParam) }"
                                    :layoutModelDetails="store.layoutModelDetails">
                                    {{model.caption}}
                                </AppPresetCaption>
                                </slot>
                            </template>
                        </AppSimpleFlexContainer>
                        </slot>
                    </template>
                    <template #container3>
                        <slot name="container3Container" :controller="controller" :store="store" :model="model" >
                        <AppSimpleFlexContainer 
                            name="container3"
                            :layoutModelDetails="store.layoutModelDetails">
                        </AppSimpleFlexContainer>
                        </slot>
                    </template>
                </AppSimpleFlexContainer>
                </slot>
            </template>
            <template #container1>
                <slot name="container1Container" :controller="controller" :store="store" :model="model" >
                <AppStandardContainer 
                    name="container1"
                    v-show="store.layoutModelDetails?.container1?.visible"
                    :isMultiContainer="false"
                    :layoutModelDetails="store.layoutModelDetails">
                    <template #container_scroll1>
                        <slot name="container_scroll1Container" :controller="controller" :store="store" :model="model" >
                        <AppScrollContainer 
                            name="container_scroll1"
                            :layoutModelDetails="store.layoutModelDetails">
                            <template #container_scroll_main1>
                                <slot name="container_scroll_main1Container" :controller="controller" :store="store" :model="model" >
                                <AppScrollContainer 
                                    name="container_scroll_main1"
                                    :layoutModelDetails="store.layoutModelDetails">
                                    <template #grid>
                                        <slot name="grid" :controller="controller" :store="store" :model="model"  :actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }">
                                        <AppCtrlPos name="grid" :layoutModelDetails="store.layoutModelDetails">
                                            <slot name="IBIZOrderMainGrid" :controller="controller" :store="store" :model="model" :actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }">
                                            <IBIZOrderMainGrid
                                                
                                                :actions="{
                                                    loadDraftAction: 'GetDraft',
                                                    createAction: 'Create',
                                                    fetchAction: 'FetchDefault',
                                                    removeAction: 'Remove',
                                                    updateAction: 'Update'
                                                }"
                                                :defaultEnableRowEdit="model.rowEditDefault"
                                                :openView="store.openView"
                                                :newView="store.newView"
                                                :singleSelect="false"
                                                name="grid"
                                                v-bind="model.ctrlParams.IBIZOrdergrid"
                                                :context="store.context"
                                                :viewParams="store.viewParams"
                                                :closeView="store.closeView"
                                                :pLoadingHelper="store.loadingHelper"
                                                :pViewCtx="store.viewCtx"
                                                @ctrl-init="(name:string, ability:any) => { handleCtrlInit(controller, name, ability) }"
                                                @ctrl-action="(name:string, action:any, data:any) => { handleCtrlAction(controller, name, action, data) }"
                                                @ctrl-destroy="(name:string, data:any) => { handleCtrlDestroy(controller, name, data) }"></IBIZOrderMainGrid>
                                            </slot>
                                            </AppCtrlPos>
                                        </slot>
                                    </template>
                                </AppScrollContainer>
                                </slot>
                            </template>
                            <template #container_scroll_header1>
                                <slot name="container_scroll_header1Container" :controller="controller" :store="store" :model="model" >
                                <AppScrollContainer 
                                    name="container_scroll_header1"
                                    :layoutModelDetails="store.layoutModelDetails">
                                    <template #searchform>
                                        <slot name="searchform" :controller="controller" :store="store" :model="model"  :actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }">
                                        <AppCtrlPos name="searchform" :layoutModelDetails="store.layoutModelDetails">
                                            <slot name="IBIZOrderUIPART_0013SearchForm" :controller="controller" :store="store" :model="model" :actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }">
                                                <IBIZOrderUIPART_0013SearchForm
                                                    :actions="{
                                                        loadDraftAction: 'GetDraft'
                                                    }"
                                                    name="searchform"
                                                    v-bind="model.ctrlParams.IBIZOrdersearchform"
                                                    :context="store.context"
                                                    :viewParams="store.viewParams"
                                                    :closeView="store.closeView"
                                                    :pLoadingHelper="store.loadingHelper"
                                                    :pViewCtx="store.viewCtx"
                                                    @ctrl-init="(name:string, ability:any) => { handleCtrlInit(controller, name, ability) }"
                                                    @ctrl-action="(name:string, action:any, data:any) => { handleCtrlAction(controller, name, action, data) }"
                                                    @ctrl-destroy="(name:string, data:any) => { handleCtrlDestroy(controller, name, data) }"    />
                                            </slot>
                                            </AppCtrlPos>
                                        </slot>
                                    </template>
                                </AppScrollContainer>
                                </slot>
                            </template>
                        </AppScrollContainer>
                        </slot>
                    </template>
                </AppStandardContainer>
                </slot>
            </template>
        </AppStandardContainer>
        </slot>
    </div>
</slot>
</template>
<script lang="ts" setup>
// 基于template/src/views/{{appModules}}/{{pages@DECUSTOMVIEW}}/{{spinalCase page.codeName}}-base.vue.hbs生成
import { AppCtrlPos, AppScrollContainer, AppSimpleFlexContainer, AppStandardContainer, AppTabPanel, AppTabPage } from '@components/layout-element/structure';

import IBIZOrderMainGrid from '@widgets/ibiz-order/main-grid/main-grid.vue';
import IBIZOrderUIPART_0013SearchForm from '@widgets/ibiz-order/uipart-0013-searchform/uipart-0013-searchform.vue';
import { useProps, useBasic, useAction, useController } from './ibiz-order-test-logic-custom-view-hook';
import { IEvent, CustomViewActionType, ICustomViewAbility, ICustomViewStore, IParam } from '@/core';

// 输入参数
const props = defineProps(useProps());

// 基础数据
const { 
    model,
    getClassNames, 
    useNavParamsBind,
	useEventBind,
    handleQuickSearch,
  	handleToolbarItemClick,
    handleComponentAction,
	handleCtrlAction,
	handleCtrlInit,
	handleCtrlDestroy
} = useBasic(props);

const emit = defineEmits<{
    (event: 'view-action', name: string, action: CustomViewActionType, data: IParam[]): void;
    (event: 'view-init', name: string, data: ICustomViewAbility): void;
    (event: 'view-mounted', name: string, data: IParam): void;
    (event: 'view-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
const classNames = computed(() => {
  	return getClassNames(props);
});

// 初始化控制器
const controller = useController(props, evt);

useNavParamsBind(controller, props);

const store: ICustomViewStore = controller.getStore();

onMounted(() => {
    controller.viewMounted();
})

onUnmounted(() => {
    controller.viewDestroy();
})
</script>
